package com.anyou.mall.dri.controller;

import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.core.page.TableDataInfo;
import com.anyou.common.enums.BusinessType;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.mall.dri.domain.IndividualAudit;
import com.anyou.mall.dri.param.IsPassIndividualAuditParam;
import com.anyou.mall.dri.service.IIndividualAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 司机加盟个人申请信息表Controller
 *
 * @author gaochaohao
 * @date 2022-03-22
 */
@Api(tags = "司机加盟个人申请信息表")
@RestController
@RequestMapping("/dri/IndividualAudit")
public class IndividualAuditController extends BaseController
{
    @Autowired
    private IIndividualAuditService individualAuditService;

    /**
     * 查询司机加盟个人申请信息表列表
     */
    @ApiOperation("查询司机加盟个人申请信息表列表")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:list')")
    @GetMapping("/list")
    public TableDataInfo<List<IndividualAudit>> list(IndividualAudit individualAudit)
    {
        startPage();
        List<IndividualAudit> list = individualAuditService.selectIndividualAuditList(individualAudit);
        return getDataTable(list);
    }

    /**
     * 导出司机加盟个人申请信息表列表
     */
    @ApiOperation("导出司机加盟个人申请信息表列表")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:export')")
    @Log(title = "司机加盟个人申请信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IndividualAudit individualAudit)
    {
        List<IndividualAudit> list = individualAuditService.selectIndividualAuditList(individualAudit);
        ExcelUtil<IndividualAudit> util = new ExcelUtil<IndividualAudit>(IndividualAudit.class);
        util.exportExcel(response, list, "司机加盟个人申请信息表数据");
    }

    /**
     * 获取司机加盟个人申请信息表详细信息
     */
    @ApiOperation("获取司机加盟个人申请信息表详细信息")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:query')")
    @GetMapping(value = "/{individualAuditId}")
    public ApiResult<IndividualAudit> getInfo(@PathVariable("individualAuditId") Long individualAuditId)
    {
        return ApiResult.success(individualAuditService.selectIndividualAuditByIndividualAuditId(individualAuditId));
    }

    /**
     * 新增司机加盟个人申请信息表
     */
    @ApiOperation("新增司机加盟个人申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:add')")
    @Log(title = "司机加盟个人申请信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody IndividualAudit individualAudit)
    {
        return ApiResult.success(individualAuditService.insertIndividualAudit(individualAudit));
    }

    /**
     * 修改司机加盟个人申请信息表
     */
    @ApiOperation("修改司机加盟个人申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:edit')")
    @Log(title = "司机加盟个人申请信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody IndividualAudit individualAudit)
    {
        return ApiResult.success(individualAuditService.updateIndividualAudit(individualAudit));
    }

    /**
     * 删除司机加盟个人申请信息表
     */
    @ApiOperation("删除司机加盟个人申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:remove')")
    @Log(title = "司机加盟个人申请信息表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{individualAuditIds}")
    public ApiResult remove(@PathVariable Long[] individualAuditIds)
    {
        return ApiResult.success(individualAuditService.deleteIndividualAuditByIndividualAuditIds(individualAuditIds));
    }

    /**
     * 是否通过审核申请
     */
    @ApiOperation("是否通过审核申请")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:isPass')")
    @Log(title = "申请详情",businessType = BusinessType.UPDATE)
    @PostMapping("/isPass")
    public ApiResult isPassIndividualAudit(@RequestBody IsPassIndividualAuditParam isPassIndividualAuditParam) {
        return individualAuditService.isPassIndividualAudit(isPassIndividualAuditParam);
    }

    /**
     * 批量通过审核
     */
    @ApiOperation("批量通过审核")
    @PreAuthorize("@ss.hasPermi('dri:IndividualAudit:allPass')")
    @Log(title = "司机加盟个人申请信息表", businessType = BusinessType.UPDATE)
    @PostMapping("/allPass/{individualAuditIds}")
    public ApiResult allPass(@PathVariable Long[] individualAuditIds) {
        return individualAuditService.allPassIndividualAudit(individualAuditIds);
    }

}
